package cn.appinfodb.controller;

import cn.appinfodb.pojo.BackendUser;
import cn.appinfodb.service.backend_user.BackendUserService;
import cn.appinfodb.tools.Constants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/backuser")
public class UserController {
    @Resource
    private BackendUserService backendUserService;
    //验证后端用户
    @RequestMapping("/login")
    public String login(String userCode, String Password,HttpSession httpSession){
        BackendUser backendUser=backendUserService.loginBackendUser(userCode,Password);
        if (null!=backendUser){
            httpSession.setAttribute(Constants.USER_SESSION,backendUser);
            return "redirect:/backuser/main";
        }else{
            return "/backendlogin.jsp";
        }
    }

    @RequestMapping("/main")
    public String main(){
        return "/WEB-INF/backend/main.jsp";
    }
}
